﻿using OddUserManager.Data.IRepositories;
using OddUserManager.Model;
using OddUserManager.Service.IServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace OddUserManager.Service.Services
{
    public class BookMarkService : IBookMarkService
    {
        private readonly IBookMarkRepository _repository;

        public BookMarkService() { }

        public BookMarkService(IBookMarkRepository repository) {
            _repository = repository;
        }

        public List<BookMark> GetAllMarkList()
        {
            return _repository.GetAllList().ToList();
        }

        public PageViewCollection<BookMark> SearchMarkPages(BookMark param, int pageIndex, int pageSize, string sortColumn, string sortDirection)
        {
            return _repository.SearchMarkPages(param,pageIndex,pageSize,sortColumn,sortDirection);
        }

        public void DeleteBatch(List<int> ids)
        {
            if (ids == null || ids.Count < 1) return;

            foreach (var i in ids)
            {
                _repository.Delete(i);
            }

        }

        public BookMark Get(int id)
        {
            return _repository.Get(id);
        }

        public IEnumerable<BookMark> GetAllList()
        {
            return _repository.GetAllList();
        }

        public bool UpdateOrInsert(BookMark entity)
        {
            return _repository.InsertOrUpdate(entity);
        }

        public List<BookMark> GetListOrderByIndex()
        {
            return _repository.GetListOrderByIndex();
        }
    }
}
